package approve.dao;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Savepoint;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import models.util.MySqlDataAccessHelper;
import approve.model.Approvedoc;
public class ApproveDocDao {
	
	
	public static int[] countall(String idEmployee, String database){
		int[] rsarray = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		ResultSet rs = null;
		String sql = "call android_countMainApprove(?)";
		try{
			helper.open(database);
			cs = helper.getConnection().prepareCall(sql);
			cs.setString(1, idEmployee);
			rs = cs.executeQuery();
			rs.next();
			rsarray[0]=rs.getInt("RePendingDoc");
			rsarray[1]=rs.getInt("ReNotApprovedDoc");
			rsarray[2]=rs.getInt("ReApprovedDoc");
			rsarray[3]=rs.getInt("ReDeclinedDoc");
			rsarray[4]=rs.getInt("ReRefApprovedDoc");
			rsarray[5]=rs.getInt("ReRefWaitingDoc");
			rsarray[6]=rs.getInt("ReMeetingDoc");
			rsarray[7]=rs.getInt("MySendingDoc");
			rsarray[8]=rs.getInt("MySavedDoc");
			rsarray[9]=rs.getInt("MyApproveDoc");
			rsarray[10]=rs.getInt("MyDeclinedDoc");
			rsarray[11]=rs.getInt("MyMeetingDoc");
			rsarray[12]=rs.getInt("BinReceiverDoc");
			rsarray[13]=rs.getInt("BinSendingDoc");
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			try {
				if(helper.getConnection() != null){
					helper.close();
				}
				if (cs != null) {
					cs.close();   	
	            }
				if(rs != null){
					rs.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}   
		}
		
		return rsarray;
	}
	
	// get All list document approve
	public static List<Approvedoc> getAllApproveGeneral(String database,String idEmployee,int stApp,int stLisapp,String sort){
		List<Approvedoc>  lstApp = new ArrayList<Approvedoc>();
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		ResultSet rs = null;
		String sql = "call android_getAllApproveGeneral(?,?,?,?)";
		try{
			helper.open(database);
			cs = helper.getConnection().prepareCall(sql);
			cs.setString(1, idEmployee);
			cs.setInt(2,stApp);
			cs.setInt(3,stLisapp);
			cs.setString(4,sort);
			rs = cs.executeQuery();
			while(rs.next()){
				lstApp.add(new Approvedoc(rs.getString("IDApproveDoc"), rs.getString("Tile"), rs.getString("Content"),
						rs.getString("IDEmployee"), rs.getString("IDGroupApprove"),
						rs.getTimestamp("Timecreate"), rs.getInt("IDStatus"),rs.getInt("IDTypeDoc"), 
						rs.getTimestamp("TimeApprove"), rs.getString("comment"), rs.getString("Description"),
						rs.getString("purpose"), rs.getString("EmployeePerforment"), rs.getTimestamp("TripDate"),
						rs.getString("TotalTime"), rs.getString("Location"), rs.getString("Content2")));
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(helper.getConnection() != null){
					helper.close();
				}
				if (cs != null) {
					cs.close();   	
	            }
				if(rs != null){
					rs.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}   
		}
		return lstApp;
	}
	
	public static List<Approvedoc> getAllApprovePending(String database,String idEmployee,int stApp,int stLisapp,String sort){
		List<Approvedoc>  lstApp = new ArrayList<Approvedoc>();
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		ResultSet rs = null;
		String sql = "call android_getAllApprovePending(?,?,?,?)";
		try{
			helper.open(database);
			cs = helper.getConnection().prepareCall(sql);
			cs.setString(1, idEmployee);
			cs.setInt(2,stApp);
			cs.setInt(3,stLisapp);
			cs.setString(4,sort);
			rs = cs.executeQuery();
			while(rs.next()){
				lstApp.add(new Approvedoc(rs.getString("IDApproveDoc"), rs.getString("Tile"), rs.getString("Content"), rs.getString("IDEmployee"), rs.getString("IDGroupApprove"), rs.getTimestamp("Timecreate"), rs.getInt("IDStatus"),rs.getInt("IDTypeDoc"), rs.getTimestamp("TimeApprove"), rs.getString("comment"), rs.getString("Description"), rs.getString("purpose"), rs.getString("EmployeePerforment"), rs.getTimestamp("TripDate"), rs.getString("TotalTime"), rs.getString("Location"), rs.getString("Content2")));
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(helper.getConnection() != null){
					helper.close();
				}
				if (cs != null) {
					cs.close();   	
	            }
				if(rs != null){
					rs.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}   
		}
		return lstApp;
	}
	
	public static List<Approvedoc> getAllDeclineGeneral(String database,String idEmployee,int stApp,int stLisapp,String sort){
		List<Approvedoc>  lstApp = new ArrayList<Approvedoc>();
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		ResultSet rs = null;
		String sql = "call android_getAllDeclineGeneral(?,?,?,?)";
		try{
			helper.open(database);
			cs = helper.getConnection().prepareCall(sql);
			cs.setString(1, idEmployee);
			cs.setInt(2,stApp);
			cs.setInt(3,stLisapp);
			cs.setString(4,sort);
			rs = cs.executeQuery();
			while(rs.next()){
				lstApp.add(new Approvedoc(rs.getString("IDApproveDoc"), rs.getString("Tile"), rs.getString("Content"), rs.getString("IDEmployee"), rs.getString("IDGroupApprove"), rs.getTimestamp("Timecreate"), rs.getInt("IDStatus"),rs.getInt("IDTypeDoc"), rs.getTimestamp("TimeApprove"), rs.getString("comment"), rs.getString("Description"), rs.getString("purpose"), rs.getString("EmployeePerforment"), rs.getTimestamp("TripDate"), rs.getString("TotalTime"), rs.getString("Location"), rs.getString("Content2")));
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(helper.getConnection() != null){
					helper.close();
				}
				if (cs != null) {
					cs.close();   	
	            }
				if(rs != null){
					rs.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}   
		}
		return lstApp;
	}
	
	//not approve
	public static List<Approvedoc> getAllNotApproveGeneral(String database,String idEmployee,int stApp,int stLisapp,String sort){
		List<Approvedoc>  lstApp = new ArrayList<Approvedoc>();
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		ResultSet rs = null;
		String sql = "call android_getAllNotApproveGeneral(?,?,?,?)";
		try{
			helper.open(database);
			cs = helper.getConnection().prepareCall(sql);
			cs.setString(1, idEmployee);
			cs.setInt(2,stApp);
			cs.setInt(3,stLisapp);
			cs.setString(4,sort);
			rs = cs.executeQuery();
			while(rs.next()){
				lstApp.add(new Approvedoc(rs.getString("IDApproveDoc"), rs.getString("Tile"), rs.getString("Content"), 
						rs.getString("IDEmployee"), rs.getString("IDGroupApprove"), rs.getTimestamp("Timecreate"),
						rs.getInt("IDStatus"),rs.getInt("IDTypeDoc"), rs.getTimestamp("TimeApprove"), rs.getString("comment"),
						rs.getString("Description"), rs.getString("purpose"), rs.getString("EmployeePerforment"), 
						rs.getTimestamp("TripDate"), rs.getString("TotalTime"), rs.getString("Location"), 
						rs.getString("Content2"),rs.getInt("is_views")));
			}
			rs.close();
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(helper.getConnection() != null){
					helper.close();
				}
				if (cs != null) {
					cs.close();   	
	            }
				if(rs != null){
					rs.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}   
		}
		return lstApp;
	}
	
	// get all reference document general
	public static List<Approvedoc> getAllReferenceDocGeneral(String database,String idEmployee,int stLisapp,String sort){
		List<Approvedoc>  lstApp = new ArrayList<Approvedoc>();
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		ResultSet rs = null;
		String sql = "call android_getAllReferenceDocGeneral(?,?,?)";
		try{
			helper.open(database);
			cs = helper.getConnection().prepareCall(sql);
			cs.setString(1, idEmployee);
			cs.setInt(2,stLisapp);
			cs.setString(3,sort);
			rs = cs.executeQuery();
			while(rs.next()){
				lstApp.add(new Approvedoc(rs.getString("IDApproveDoc"), rs.getString("Tile"), rs.getString("Content"), rs.getString("IDEmployee"), rs.getString("IDGroupApprove"), rs.getTimestamp("Timecreate"), rs.getInt("IDStatus"),rs.getInt("IDTypeDoc"), rs.getTimestamp("TimeApprove"), rs.getString("comment"), rs.getString("Description"), rs.getString("purpose"), rs.getString("EmployeePerforment"), rs.getTimestamp("TripDate"), rs.getString("TotalTime"), rs.getString("Location"), rs.getString("Content2")));
			}
			rs.close();
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(helper.getConnection() != null){
					helper.close();
				}
				if (cs != null) {
					cs.close();   	
	            }
				if(rs != null){
					rs.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}   
		}
		return lstApp;
	}
	
	// get all meeting document pending 
	public static List<Approvedoc> getAllMeetingDocPending(String database,String idEmployee,String sort){
		List<Approvedoc>  lstApp = new ArrayList<Approvedoc>();
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		ResultSet rs = null;
		String sql = "call android_getAllMeetingDocPending(?,?)";
		try{
			helper.open(database);
			cs = helper.getConnection().prepareCall(sql);
			cs.setString(1, idEmployee);
			cs.setString(2,sort);
			rs = cs.executeQuery();
			while(rs.next()){
				lstApp.add(new Approvedoc(rs.getString("IDApproveDoc"), rs.getString("Tile"), rs.getString("Content"),
						rs.getString("IDEmployee"), rs.getString("IDGroupApprove"), rs.getTimestamp("Timecreate"),
						rs.getInt("IDStatus"),rs.getInt("IDTypeDoc"), rs.getTimestamp("TimeApprove"), 
						rs.getString("comment"), rs.getString("Description"), rs.getString("purpose"), 
						rs.getString("EmployeePerforment"), rs.getTimestamp("TripDate"), rs.getString("TotalTime"),
						rs.getString("Location"), rs.getString("Content2"),rs.getInt("is_views")));
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(helper.getConnection() != null){
					helper.close();
				}
				if (cs != null) {
					cs.close();   	
	            }
				if(rs != null){
					rs.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}   
		}
		return lstApp;
	}
	
	// get total amount
	public static float getTotalAmount(String databasename, String iDApproveDoc) {
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		mysql.open(databasename);
		float totalAmount = 0.0f;
		try {
			String sql = "select SUM(bd.total) as total  from buying_document bd where bd.document_id="+ iDApproveDoc + " limit 1";
			ResultSet rs = mysql.executeQuery(sql);
			while (rs.next()) {
				totalAmount = rs.getFloat("total");
				break;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				mysql.close();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}
		return totalAmount;
	}
	
	public static int deleteMydocumentSending(String id,String database){
		int kq = -1;
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		try{
			helper.open(database);
			String sql = "DELETE FROM approvedoc WHERE IDApproveDoc = '"+id+"' ";
			kq = helper.executeUpdate(sql);
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			helper.close();
		}
		return kq;
	}
	
	public static boolean updateIsView(String database,String id){
		int a = 0;
		String sql ="update approvedoc set isView=1 where IDApproveDoc='"+id+"'";
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		try {
			mysql.open(database);
			a = mysql.executeUpdate(sql); 
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			mysql.close();
		}
		return a>0;
	}
	
	// get all list app in my sending recycle bin
	public static List<Approvedoc> getAllApproveDocSendingRecyle(String database,String idemployee,int status,String sort){
		List<Approvedoc>  lstApp = new ArrayList<Approvedoc>();
		MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		ResultSet rs = null;
		String sql = "call android_getAllApproveDocSendingRecyle(?,?,?)";
		try{
			helper.open(database);
			cs = helper.getConnection().prepareCall(sql);
			cs.setString(1, idemployee);
			cs.setInt(2,status);
			cs.setString(3,sort);
			rs = cs.executeQuery();
			while(rs.next()){
				lstApp.add(new Approvedoc(rs.getString("IDApproveDoc"), rs.getString("Tile"), rs.getString("Content"), rs.getString("IDEmployee"), rs.getString("IDGroupApprove"), rs.getTimestamp("Timecreate"), rs.getInt("IDStatus"),rs.getInt("IDTypeDoc"), rs.getTimestamp("TimeApprove"), rs.getString("comment"), rs.getString("Description"), rs.getString("purpose"), rs.getString("EmployeePerforment"), rs.getTimestamp("TripDate"), rs.getString("TotalTime"), rs.getString("Location"), rs.getString("Content2")));
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(helper.getConnection() != null){
					helper.close();
				}
				if (cs != null) {
					cs.close();   	
	            }
				if(rs != null){
					rs.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}   
		}
		return lstApp;
	}
	
	// delete my decline document
	public static boolean deleteMyappDecline(String value,String database){
		int row = 0;
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		PreparedStatement ps = null;
		ResultSet rs = null;
		try {
			mysql.open(database);
			String sql = "UPDATE approvedoc set IDStatus = 6 WHERE IDApproveDoc in (" + value + ")";
			ps = mysql.getConnection().prepareStatement(sql);
			row = ps.executeUpdate();
		} catch (Exception ex) {
			ex.printStackTrace(System.out);
		} finally {
			mysql.close();
			try{
				if(ps != null){
					ps.close();
				}
				if(rs != null){
					rs.close();
				}
			}catch (Exception e) {
				e.printStackTrace(System.out);
			}
		}
		return row > 0;
	}
	
	//* Delete not backup *//
	public static  void deleteNotBackup(Approvedoc document,String database) {
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		try {
			mysql.open(database);
			java.sql.Connection conn = mysql.getConnection();
			conn.setAutoCommit(false);
			Savepoint sv1 = conn.setSavepoint("svpt1");
			Statement stmt = conn.createStatement();
			try {
				String sql1 = "delete FROM listapprove where IDGroupApprove='"
						+ document.getiDGroupApprove() + "'";
				stmt.executeUpdate(sql1);

				String sql2 = "delete FROM list_reference where id_group='"
						+ document.getiDGroupApprove() + "'";
				stmt.executeUpdate(sql2);

				String sql = String.format(
						"DELETE FROM approvedoc WHERE IDApproveDoc = '%s'",
						document.getiDApproveDoc());
				stmt.executeUpdate(sql);

				conn.commit();

			} catch (Exception ex) {
				try {
					ex.printStackTrace();
					conn.rollback(sv1);
					System.out.println("Rollback ..............");
				} catch (Exception e1) {
					e1.printStackTrace();
					System.out.println("Error in delete");
				}
			} finally {
				conn.releaseSavepoint(sv1);
				mysql.close();
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			System.out.println("Error in rollback");
		}
	}
	
	// delete recyle bin sending document
	public static boolean deleteDataBackup(Approvedoc app,String database) {
		int row = 0;
		try {
			MySqlDataAccessHelper mysqlHelper = new MySqlDataAccessHelper();
				mysqlHelper.open(database);
				java.sql.Connection conn = mysqlHelper.getConnection();
				conn.setAutoCommit(false);
				Savepoint sv1 = conn.setSavepoint("svpt1");
				Statement stmt = conn.createStatement();
				try {
					String sqlItems = String.format("DELETE FROM buying_document WHERE document_id = '%s'",app.getiDApproveDoc());
					row += stmt.executeUpdate(sqlItems);
					
					String sqlAdvs = String.format("DELETE FROM ap_advance where document_id  = '%s'",app.getiDApproveDoc());
					row += stmt.executeUpdate(sqlAdvs);
					
					String sql1 = String.format("delete FROM listapprove where IDGroupApprove = '%s'",app.getiDGroupApprove());
					row += stmt.executeUpdate(sql1);

					String sql2 = String.format("delete FROM list_reference where id_group = '%s'",app.getiDGroupApprove());
					row += stmt.executeUpdate(sql2);

					String sql = String.format("DELETE FROM approvedoc WHERE IDApproveDoc = '%s'",app.getiDApproveDoc());
					row += stmt.executeUpdate(sql);

					conn.commit();

				} catch (Exception ex) {
					try {
						ex.printStackTrace();
						conn.rollback(sv1);
						row = 0;
						System.out.println("Rollback ..............");
					} catch (Exception e1) {
						e1.printStackTrace();
						System.out.println("Error in delete");
					}
				} finally {
					conn.releaseSavepoint(sv1);
					mysqlHelper.close();
				}
			} catch (Exception ex) {
				ex.printStackTrace();
				System.out.println("Error in rollback");
			}
			return row > 0;	
	}	
	
	// restore form 14
	
	public static boolean restore(Approvedoc doc,String database ){
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		int a = 0;
		String sql1 ="select IDStatus from listapprove where IDGroupApprove = ?";
		String sql2 = "update approvedoc set IDStatus = ? where IDGroupApprove = ?";
		ResultSet rs = null;
		PreparedStatement ps = null;
		try {
			mysql.open(database);
			ps = mysql.getConnection().prepareStatement(sql1);
			ps.setString(1,doc.getiDGroupApprove());
			int b=0;
			rs = ps.executeQuery();
			while(rs.next()){
				if(rs.getInt("IDStatus")==2){
					b=2;
					break;
				}else if(rs.getInt("IDStatus")==3){
					b=3;
					break;
				}else{
					b=1;
				}
			}
			ps = mysql.getConnection().prepareStatement(sql2);
			ps.setInt(1, b);
			ps.setString(2, doc.getiDGroupApprove());
			a = ps.executeUpdate();
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			try {
				ps.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
			mysql.close();
			
		}
		return a>0;		
	}
	
	public static ArrayList<Approvedoc> getAllDocByLabel(String idEmp, int label,String database,String sort) {
		ArrayList<Approvedoc> lst = new ArrayList<Approvedoc>();
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		CallableStatement cs = null;
		CallableStatement cs2 = null;
		CallableStatement cs3 = null;
		
		String sql = "SELECT a.*,a.isView AS is_views,a.IDLabel as IDLabel FROM approvedoc a " +
				"WHERE a.IDEmployee ='"+idEmp+"' AND a.IDLabel = '"+label+"' ORDER BY a.Timecreate "+sort;
		
		String sql2 = "SELECT a.*,f.id_status AS is_views,a.IDLabel as IDLabel FROM approvedoc a " +
				"INNER JOIN list_reference f ON  a.IDGroupApprove = f.id_group " +
				"WHERE f.IDLabel ='"+label+"' AND f.id_employee ='"+idEmp+"' ORDER BY a.Timecreate "+sort;
		
		String sql3 = "SELECT a.*,b.isView AS is_views,a.IDLabel as IDLabel FROM approvedoc a " +
				"INNER JOIN listapprove b ON  a.IDGroupApprove = b.IDGroupApprove " +
				"WHERE b.IDLabel ='"+label+"' AND b.IDEmployee ='"+idEmp+"' ORDER BY a.Timecreate "+sort;
		try {
			mysql.open(database);
			
			//---Update old ListApprove Label-----------
			int rows=0;
			String sqlOld1 = "UPDATE listapprove SET IDLabel = IDStatus WHERE IDStatus > 10";
			rows=mysql.executeUpdate(sqlOld1);//------------
			if(rows>=1){
				String sqlOld2 = "UPDATE listapprove l SET l.IDStatus=(SELECT a.IDStatus FROM approvedoc a WHERE a.IDGroupApprove=l.IDGroupApprove) WHERE l.IDStatus > 10";
				mysql.executeUpdate(sqlOld2);//------------			
			}
			
			cs = mysql.getConnection().prepareCall(sql);
			ResultSet rs = cs.executeQuery();
			
			cs2 = mysql.getConnection().prepareCall(sql2);
			ResultSet rs2 = cs2.executeQuery();
			
			cs3 = mysql.getConnection().prepareCall(sql3);
			ResultSet rs3 = cs3.executeQuery();
			
			while (rs.next()) {
				if (rs.getInt("IDTypeDoc") != 11) {
					lst.add(new Approvedoc(rs.getString("IDApproveDoc"), rs
							.getString("Tile"), rs.getString("Content"), rs
							.getString("IDEmployee"), rs
							.getString("IDGroupApprove"), rs
							.getTimestamp("Timecreate"), rs.getInt("IDStatus"),
							rs.getInt("IDTypeDoc"), rs
									.getTimestamp("TimeApprove"), rs
									.getString("comment"), rs
									.getString("Description"), rs
									.getString("purpose"), rs
									.getString("EmployeePerforment"), rs
									.getTimestamp("TripDate"), rs
									.getString("TotalTime"), rs
									.getString("Location"), rs
									.getString("Content2"), rs
									.getInt("is_views"), rs
									.getInt("IDLabel")));
				}
			}				
			
			while (rs2.next()) {
				if (rs2.getInt("IDTypeDoc") != 11) {
					lst.add(new Approvedoc(rs2.getString("IDApproveDoc"), rs2
							.getString("Tile"), rs2.getString("Content"), rs2
							.getString("IDEmployee"), rs2
							.getString("IDGroupApprove"), rs2
							.getTimestamp("Timecreate"), rs2.getInt("IDStatus"),
							rs2.getInt("IDTypeDoc"), rs2
									.getTimestamp("TimeApprove"), rs2
									.getString("comment"), rs2
									.getString("Description"), rs2
									.getString("purpose"), rs2
									.getString("EmployeePerforment"), rs2
									.getTimestamp("TripDate"), rs2
									.getString("TotalTime"), rs2
									.getString("Location"), rs2
									.getString("Content2"), rs2
									.getInt("is_views"), rs2
									.getInt("IDLabel")));
				}
			}				
			
			while (rs3.next()) {
				if (rs3.getInt("IDTypeDoc") != 11) {
					lst.add(new Approvedoc(rs3.getString("IDApproveDoc"), rs3
							.getString("Tile"), rs3.getString("Content"), rs3
							.getString("IDEmployee"), rs3
							.getString("IDGroupApprove"), rs3
							.getTimestamp("Timecreate"), rs3.getInt("IDStatus"),
							rs3.getInt("IDTypeDoc"), rs3
									.getTimestamp("TimeApprove"), rs3
									.getString("comment"), rs3
									.getString("Description"), rs3
									.getString("purpose"), rs3
									.getString("EmployeePerforment"), rs3
									.getTimestamp("TripDate"), rs3
									.getString("TotalTime"), rs3
									.getString("Location"), rs3
									.getString("Content2"), rs3
									.getInt("is_views"), rs3
									.getInt("IDLabel")));
				}
			}				
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			mysql.close();
		}
		return lst;
	}
}